package com.baizhi.cmfz.service.impl;

import com.baizhi.cmfz.annotation.LogAnnotation;
import com.baizhi.cmfz.entity.CmfzBanner;
import com.baizhi.cmfz.mapper.CmfzBannerMapper;
import com.baizhi.cmfz.service.CmfzBannerService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Transactional
@Service
public class CmfzBannerServiceImpl  implements CmfzBannerService {

    @Autowired
    private CmfzBannerMapper cbm;

    //分页查看所有轮播图
    public Page<CmfzBanner> selectAllByPage(Integer page, Integer limit){
        Page<CmfzBanner> bannerPage1 = new Page<>(page, limit);
        Page<CmfzBanner> bannerPage = cbm.selectPage(bannerPage1, null);
        return bannerPage;
    }

    //添加轮播图
    @LogAnnotation(type = "insert",value = "添加轮播图")
    public void insertBanner(CmfzBanner b){
        cbm.insert(b);
    }

    @Override
    @LogAnnotation(type = "update",value = "修改轮播图状态")
    public void updateStatus(CmfzBanner b) {
        cbm.updateStatus(b);
    }


}
